package com.bawei.yangzongcai___chenmei.MaiuActivity;

import android.widget.RadioButton;
import android.widget.RadioGroup;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.bawei.yangzongcai___chenmei.Adpter.FragementOne;
import com.bawei.yangzongcai___chenmei.BlankFragment.Blanck2.BlankFragmentQAQ1;
import com.bawei.yangzongcai___chenmei.BlankFragment.Blanck2.BlankFragmentQAQ2;
import com.bawei.yangzongcai___chenmei.BlankFragment.Blanck2.BlankFragmentQAQ3;
import com.bawei.yangzongcai___chenmei.BlankFragment.Blanck2.BlankFragmentQAQ4;
import com.bawei.yangzongcai___chenmei.BlankFragment.Blanck2.BlankFragmentQAQ5;
import com.bawei.yangzongcai___chenmei.BlankFragment.Blanck2.BlankFragmentQAQ6;
import com.bawei.yangzongcai___chenmei.MVC.BsaeActivity;
import com.bawei.yangzongcai___chenmei.R;

import java.util.ArrayList;

public class MainActivity2 extends BsaeActivity {

    private ViewPager main2Vp;
    private RadioGroup main2Rg;
    private RadioButton main2Bt1;
    private RadioButton main2Bt2;
    private RadioButton main2Bt3;
    private RadioButton main2Bt4;
    private RadioButton main2Bt5;
    private RadioButton main2Bt6;

    @Override
    public int bandLayout() {
        return R.layout.activity_main2;
    }

    @Override
    public void initView() {

        main2Vp = findViewById(R.id.main2_vp);
        main2Rg = findViewById(R.id.main2_rg);
        main2Bt1 = findViewById(R.id.main2_bt1);
        main2Bt2 = findViewById(R.id.main2_bt2);
        main2Bt3 = findViewById(R.id.main2_bt3);
        main2Bt4 = findViewById(R.id.main2_bt4);
        main2Bt5 = findViewById(R.id.main2_bt5);
        main2Bt6 = findViewById(R.id.main2_bt6);
    }

    @Override
    public void initDate() {

        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(new BlankFragmentQAQ1());
        fragments.add(new BlankFragmentQAQ2());
        fragments.add(new BlankFragmentQAQ3());
        fragments.add(new BlankFragmentQAQ4());
        fragments.add(new BlankFragmentQAQ5());
        fragments.add(new BlankFragmentQAQ6());

        FragementOne fragementOne = new FragementOne(getSupportFragmentManager(),fragments);
        main2Vp.setAdapter(fragementOne);

        main2Rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId)
                {
                    case R.id.main2_bt1:
                        main2Vp.setCurrentItem(0);
                        break;

                    case R.id.main2_bt2:
                        main2Vp.setCurrentItem(1);
                        break;

                    case R.id.main2_bt3:
                        main2Vp.setCurrentItem(2);
                        break;

                    case R.id.main2_bt4:
                        main2Vp.setCurrentItem(3);
                        break;

                    case R.id.main2_bt5:
                        main2Vp.setCurrentItem(4);
                        break;

                    case R.id.main2_bt6:
                        main2Vp.setCurrentItem(5);
                        break;
                }
            }
        });
    }
}
